/**
 *  初始化layui
 */
$(function () {
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;
        laydate.render({
            elem: '#deadline',
            max: 1,
            value: PEMS.formateDate(new Date(), 'yyyy-MM-dd')
        });
    })
});

$(function () {
    getResumeDetailById();

    $("#saveAResume").on("click",function () {
        $("#saveAResume").css("disabled","true");

        $.ajax({
            url: WebContext + "/cardRecord/updateCardRecord",
            data: {
                id:$("#id").val(),
                cusName: $("#cusName").val(),
                cusPhone: $("#cusPhone").val(),
                carRecord: $("#carRecord").val(),
                createTime: new Date($("#deadline").val()),
                maintenanceFees: $("#maintenanceFees").val(),
                carType: $("#carType").val()
            },
            type: "post",
            dataType: "json",
            success: function (data) {
                if (data.success == true) {
                    PEMS.openInFoWindow("提示信息", "数据更新成功", function () {
                        loading(1);
                        getIframeWindowByContent("首页").tableRefresh("resourceTable", true, null, null);
                        closeByBtnInSubPage(getITagByContent("编辑维修记录"));
                    });
                }
            }
        });
    });

});
function getResumeDetailById() {
    var id = getQueryParamsAndValuesFromUrl().id;
    $.ajax({
        url: WebContext + "/cardRecord/getById?id=" + id,
        type: "post",
        dataType: "json",
        async: false,
        success: function (data) {
            $("#deadline").val((PEMS.formateDate(data.createTime, "yyyy-MM-dd")));
            // cusName cusPhone  carRecord  id
            $("#cusName").val(data.cusName);
            $("#cusPhone").val(data.cusPhone);
            $("#carRecord").val(data.carRecord);
            $("#maintenanceFees").val(data.maintenanceFees);
            $("#id").val(data.id);
            $("#carType").val(data.carType);
        }
    });
}


